package com.mall.shopping.converter;

import com.mall.shopping.dal.entitys.Panel;
import com.mall.shopping.dal.entitys.PanelContentItem;
import com.mall.shopping.dto.PanelContentDto;
import com.mall.shopping.dto.PanelContentItemDto;
import com.mall.shopping.dto.PanelDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lichao
 * @createdate 2021-01-26 10:41
 */

@Mapper(componentModel = "spring")
public interface PanelItemConvertor {
    @Mappings({})
    PanelDto panel2Dto(Panel panel);

    @Mappings({})
    List<PanelDto> panel2Dto(List<Panel> panel);
    @Mappings({})
    PanelContentItemDto content2ContentDto(PanelContentItem contentItem);

    default List<PanelContentItemDto> convert(List<PanelContentItem> panelContentItems){
        List<PanelContentItemDto> panelContentItemDtos = new ArrayList<>();
        for (PanelContentItem panelContentItem : panelContentItems) {
            panelContentItemDtos.add(content2ContentDto(panelContentItem));
        }
        return panelContentItemDtos;
    }

}
